﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Jzb.ConsoleApp
{
    public abstract class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string Gender { get; protected set; }

        //public void Speak()
        //{
        //    Console.WriteLine($"{Gender}性的{Name}正在讲话");
        //}

        public void Func1()
        {
            Console.WriteLine("Func1");
        }
        public virtual void Func2()//虚方法也可以在子类中实现
        {
            Console.WriteLine("Func2");
        }
        public abstract void Func3();//抽象方法必须在子类中必须实现
    }

    public class Man : Person
    {
        public double dingding;
        public Man()
        {
            this.Gender = "男";
        }

        public override void Func3()
        {
            throw new NotImplementedException();
        }
    }
    public class Woman : Person
    {
        public Woman()
        {
            this.Gender = "女";

        }

        public override void Func3()
        {
            throw new NotImplementedException();
        }
    }
    public interface IPerson
    {
        void Speak();//在接口中声明方法,接口方法在实现类中必须重写
    }

    //只能继承一个基类
    //可以继承多个接口
    public class Chinese : Person,IPerson
    {
        public void Speak()//子类中重写方法
        {
            Console.WriteLine("讲中文");
        }

        public override void Func2()//重写基类里的虚方法
        {
            Console.WriteLine("Chinese Func2");
        }

        public new void Func1()
        {
            Console.WriteLine("Chinese Func1");

        }

        public override void Func3()
        {
            throw new NotImplementedException();
        }
    }
    public class Foregin : Person, IPerson
    {
        public override void Func3()
        {
            throw new NotImplementedException();
        }

        public void Speak()
        {
            Console.WriteLine("讲英文");
        }
    }
}
